package com.audaque.springboot.foshanupload.core.converter;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.util.Date;

/**
 * @author zgb
 * @desc 不用于全局配置
 * @date 2021-12-30 14:07:17
 */
public class DateJacksonSerialize2LongConverter extends JsonSerializer<Date> {

    @Override
    public void serialize(Date value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeNumber(value.toInstant().toEpochMilli());
    }
}


